package com.docmanage.am.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 * 
 * @author ry
 */
@Data
public class CabinetTreeSelect implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private Long id;

    /** 节点名称 */
    private String label;

    private List<AmCabinet> contentList;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<CabinetTreeSelect> children;

    public CabinetTreeSelect()
    {

    }

    public CabinetTreeSelect(AmCabinet amCabinet)
    {
        this.id = amCabinet.getId();
        this.label = amCabinet.getName();
        this.children = amCabinet.getChildren().stream().map(CabinetTreeSelect::new).collect(Collectors.toList());
    }

    public CabinetTreeSelect(Object o) {
        AmCabinet amCabinet = (AmCabinet)o;
        this.id = amCabinet.getId();
        this.label = amCabinet.getName();
        this.children = amCabinet.getChildren().stream().map(CabinetTreeSelect::new).collect(Collectors.toList());
    }


}
